#include <iostream>
using namespace std;

#define NORTH   8
#define SOUTH   3
#define WEST    6
#define EAST    5
#define MAXDEPTH    15

int leastSteps = 1000000;

void stepper(int x, int y, int steps){
    if(x == 0 && y == 0){
        if(steps<leastSteps)
            leastSteps = steps;
        return;
        }

    if(steps>MAXDEPTH || steps > leastSteps) return;

    stepper(x, y+NORTH, steps+1);
    stepper(x, y-SOUTH, steps+1);
    stepper(x+EAST, y, steps+1);
    stepper(x-WEST, y, steps+1);

    return;
}


int main(string args[]){
    int x, y;
    cout << "Start x: "; cin >> x;
    cout << "Start y: "; cin >> y;

    stepper(x, y+NORTH, 1);
    stepper(x, y-SOUTH, 1);
    stepper(x+EAST, y, 1);
    stepper(x-WEST, y, 1);

    cout << endl << leastSteps << " steps is needed" << endl;
}

